package keeto.com.vn.classified.task;

import java.io.IOException;

import org.apache.http.client.ClientProtocolException;
import org.json.JSONException;

import keeto.com.vn.classified.core.ClassifiedCore;
import keeto.com.vn.classified.core.ClassifiedListener;
import keeto.com.vn.classified.network.IProtocol;
import keeto.com.vn.classified.request.ChangePassRequest;
import keeto.com.vn.classified.response.ChangePassResponse;

public class TaskChangePass extends AbstractTask{
	String oldPass;
	String newPass;
	String authenKey;
	public TaskChangePass(ClassifiedListener listener, ClassifiedCore core,String oldPass, String newPass, String authKey) {
		super(listener, core);
		// TODO Auto-generated constructor stub
		this.authenKey=authKey;
		this.newPass=newPass;
		this.oldPass=oldPass;
	}

	@Override
	public void run() throws ClientProtocolException, JSONException,
			IOException {
		// TODO Auto-generated method stub
		ChangePassRequest request = new ChangePassRequest();
		request.setAuthKey(authenKey);
		request.setNewPass(newPass);
		request.setOldPass(oldPass);
		ChangePassResponse response = json.finishChangePass(request);
		for (ClassifiedListener mListener : listeners) {
			mListener.finishChangePass(response.getReturnCode(),response.getRessultMsg());
		}
		
	}

	@Override
	public void timeoutCallback() {
		// TODO Auto-generated method stub
		for (ClassifiedListener mListener : listeners) {
			mListener.finishChangePass(IProtocol.STATUS_CODE_GENERICFAIL_500,"");
		}
	}

}
